from sitepal.sitetheme.renderers import ApplicationRenderer

class MenuRenderer(ApplicationRenderer):
    def contribute_to_theme(self):
        return {
            'render_navigation'   : self.render_navigation,
            'render_welcome_login': self.render_welcome_login,
            'render_welcome_user' : self.render_welcome_user,
        }

    def render_navigation(self,links,attributes={}):
        if links:
            return self.render_links(links,list_type='ol',attributes=attributes)
        return u''

    def render_welcome_login(self,login,msg=None,request=None):
        if login:
            context = self.user_context(request) if request else {}
            context.update({
                'welcome' : msg or u'',
                'login'   : login,
            })
            return self.render_template('menu/welcome-login.html',context)
        return u''

    def render_welcome_user(self,profile,logout,msg=None,request=None):
        if logout and profile:
            context = self.user_context(request) if request else {}
            context.update({
                'welcome' : msg or u'',
                'profile' : profile,
                'logout'  : logout,
            })
            return self.render_template('menu/welcome-user.html',context)
        return u''

